package com.trhui.mallbook.client;

import com.trhui.mallbook.domain.common.ApiRequest;
import com.trhui.mallbook.domain.common.BaseResponse;
import com.trhui.mallbook.domain.request.dg.DgDivBackRequest;
import com.trhui.mallbook.domain.request.hf.HfDivBackRequest;
import com.trhui.mallbook.domain.request.yb.YbDivBackRequest;
import com.trhui.mallbook.domain.response.dg.DgDivBackResponse;
import com.trhui.mallbook.domain.response.hf.HfDivBackResponse;
import com.trhui.mallbook.domain.response.yb.YbDivBackResponse;
import com.trhui.mallbook.enums.ChannelTypeEnum;
import com.trhui.mallbook.enums.ServerCodeEnum;

/**
 * 分账归还
 * @author linqy
 */
public class DivBackClient extends AbstractClient {

    /**
     * YB分账归还
     *
     * @param request
     * @return
     */
    public static BaseResponse<YbDivBackResponse> ybDivBack(YbDivBackRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.DIV_BACK)
                .channelType(ChannelTypeEnum.YB)
                .build();
        return post(reqApiRequest, YbDivBackResponse.class);
    }

    /**
     * HF分账归还
     *
     * @param request
     * @return
     */
    public static BaseResponse<HfDivBackResponse> hfDivBack(HfDivBackRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.DIV_BACK)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(reqApiRequest, HfDivBackResponse.class);
    }

    /**
     * DG分账归还
     *
     * @param request
     * @return
     */
    public static BaseResponse<DgDivBackResponse> dgDivBack(DgDivBackRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.DIV_BACK)
                .channelType(ChannelTypeEnum.DG)
                .build();
        return post(reqApiRequest, DgDivBackResponse.class);
    }
}
